package com.example.administrator.waitan.homepage;

import android.util.Log;

import com.example.administrator.waitan.mygreendao.DaoSession;
import com.example.administrator.waitan.mygreendao.HomeData;

import java.util.List;

/**
 * Created by Administrator on 2016/1/22.
 */
public class HomePagerHelper {
    private DaoSession daoSession;
    private static HomePagerHelper homePagerHelper;
    public static  HomePagerHelper getHomePagerHelper(){
        if (homePagerHelper == null){
            homePagerHelper = new HomePagerHelper();
        }
        return homePagerHelper;
    }

    public HomePagerHelper() {
        daoSession = com.example.administrator.waitan.base.BaseApplication.getDaoSession();
    }
    public List<HomeData> queryAll(){
                  if (daoSession.getHomeDataDao().loadAll()==null){
                      return null;
                  }else{

        return daoSession.getHomeDataDao().loadAll();
                  }
//        Log.d("aaaa", daoSession.getHomeDataDao().loadAll().size() +"");
    }

    public void deleteAll() {
        daoSession.getHomeDataDao().deleteAll();

    }

    public void addAll(List<HomeData> datas){
        daoSession.getHomeDataDao().insertInTx(datas);
    }

}
